package com.lsege.controller;

import com.lsege.entity.JsonResult;
import com.lsege.util.OssUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.processing.FilerException;
import java.io.FileNotFoundException;

/**
 * Created by Administrator on 2017/7/21 0021.
 */
@RestController
/**
 *
 */
@RequestMapping(value = "upload")
public class UploadController {
    @PostMapping(value = "uploadPrizePic")
    public JsonResult uploadPrizePic(MultipartFile file) throws FileNotFoundException{
        JsonResult json=new JsonResult();
        if(file!=null){
            String url= OssUtil.uploadFile(file);
            json.setData(url);
            json.setMessage("图片上传成功");
            json.setSuccess(true);
        }else {
            json.setSuccess(false);
            json.setMessage("图片上传失败");
        }
        return json;
    }
}
